package com.hospital.registration.web;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hospital.common.dto.RegistrationDto;
import com.hospital.common.vo.ResultEntity;
import com.hospital.registration.entity.Registration;
import com.hospital.registration.entity.Sickperson;
import com.hospital.registration.service.IRegistrationService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 挂号记录表 前端控制器
 * </p>
 *
 * @author 史永康
 * @since 2020-10-22
 */
@RestController
@RequestMapping("/registration")
public class RegistrationController {

    @Autowired
    IRegistrationService iRegistrationService;

    @RequestMapping("/list")
    public ResultEntity findall(Page page, RegistrationDto registrationDto){
        IPage<Registration> findall = iRegistrationService.findall(page, registrationDto);
        return ResultEntity.ok("操作成功",findall);
    }

    @RequestMapping("/add")
    public ResultEntity add(RegistrationDto registrationDto){
        System.err.println(registrationDto);
        Registration registration = new Registration();
        BeanUtils.copyProperties(registrationDto,registration);
        boolean save = iRegistrationService.save(registration);
        return ResultEntity.ok("成功",save);
    }


    //退号操作
    public ResultEntity del(RegistrationDto registrationDto){
        boolean b = iRegistrationService.removeById(registrationDto.getId());

        return ResultEntity.ok("成功",b);
    }

}
